<html>
<head>
  <title>22-锁</title>
  <basefont face="微软雅黑" size="2" />
  <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
  <meta name="exporter-version" content="YXBJ Windows/600646 (zh-CN, DDL); Windows/6.1.1 (Win64);"/>
  <meta name="content-class" content="yinxiang.markdown"/>
  <style>
    body, td {
      font-family: 微软雅黑;
      font-size: 10pt;
    }
  </style>
</head>
<body>
<a name="1153"/>
<h1>22-锁</h1>

<div><span><div style="font-size: 14px; margin: 0; padding: 0; width: 100%;"><h2 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 34px; border-bottom: 1px solid #dbdbdb; color: #333;">1 解决并发事务带来的问题：两种解决方式</h2>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">上一章讲述了事务并发执行时可能带来的各种问题，并发事务访问相同记录的情况大致可以划分为3种：</p>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">读-读</h4>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">即并发事务相继读取相同的记录。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">读取操作本身不会对记录有影响，所以允许这种情况的发生。</p>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">写-写</h4>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">这种情况下会发生<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">脏写</strong>的问题，任何一种隔离级别都不允许这种问题的发生。所以在多个未提交事务相继对一条记录做改动时，需要让它们排队执行，这个排队的过程其实是通过<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">锁</strong>来实现的。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">这个<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">锁</strong>其实是一个内存中的结构，在事务执行前本来是没有锁的，也就是说一开始是没有<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">锁结构</strong>和记录进行关联的，如图：<br/>
<img src="22-锁_files/1.jpg" type="image/jpeg" data-filename="1.jpg"/></p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">当一个事务想对这条记录做改动时，首先会看看内存中有没有与这条记录关联的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">锁结构</strong>，当没有的时候就会在内存中生成一个<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">锁结构</strong>与之关联。比方说事务T1要对这条记录做改动，就需要生成一个<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">锁结构</strong>与之关联：<br/>
<img src="22-锁_files/1 [1].jpg" type="image/jpeg" data-filename="1.jpg"/></p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">其实在锁结构里有很多信息，不过为了简化理解，现在只把两个比较重要的属性拿了出来：</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">trx信息</strong>：代表这个锁结构是哪个事务生成的；</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">is_waiting</strong>：代表当前事务是否在等待；</li>
</ul>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">如图所示，当事务T1改动了这条记录后，就生成了一个<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">锁结构</strong>与该记录关联，因为之前没有别的事务为这条记录加锁，所以<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">is_waiting属性就是false</strong>，把这个场景就称之为<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">获取锁成功</strong>，或者<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">加锁成功</strong>，然后就可以继续执行操作了。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">在事务T1提交之前，另一个事务T2也想对该记录做改动，那么先去看看有没有锁结构与这条记录关联，发现有一个锁结构与之关联后，然后也生成了一个锁结构与这条记录关联，不过锁结构的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">is_waiting属性值为true</strong>，表示当前事务需要等待，把这个场景就称之为获取锁失败，或者加锁失败，或者没有成功的获取到锁，画个图表示就是这样：<br/>
<img src="22-锁_files/1 [2].jpg" type="image/jpeg" data-filename="1.jpg"/></p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">在事务T1提交之后，就会把该事务生成的锁结构释放掉，然后看看还有没有别的事务在等待获取锁，发现了事务T2还在等待获取锁，所以把事务T2对应的锁结构的is_waiting属性设置为false，然后把该事务对应的线程唤醒，让它继续执行，此时事务T2就算获取到锁了。效果图就是这样：<br/>
<img src="22-锁_files/1 [3].jpg" type="image/jpeg" data-filename="1.jpg"/></p>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">读-写/写-读</h4>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">也就是一个事务进行读取操作，另一个进行修改操作。<br/>
上一章说过，这种情况下，可能发生<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">脏读、不可重复读、幻读</strong>的问题。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">怎么解决<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">脏读、不可重复读、幻读</strong>问题呢？有两种可选方案：</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;">方案一：<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">读操作</strong>利用<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">MVCC（多版本并发控制）</strong>，这种方式也称为<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">快照读</strong>，<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">写操作</strong>进行<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">加锁</strong>；<br/>
所谓的MVCC在前一章有过详细的描述，就是通过版本链和ReadView，然后通过ReadView找到符合条件的记录版本（历史版本是由undo日志构建的），其实就像是在生成ReadView的那个时刻做了一次时间静止（就像用相机拍了一个快照），查询语句只能读到在生成ReadView之前已提交事务所做的更改，在生成ReadView之前未提交的事务或者之后才开启的事务所做的更改是看不到的。而写操作肯定针对的是最新版本的记录，读记录的历史版本和改动记录的最新版本本身并不冲突，也就是采用MVCC时，读-写操作并不冲突。<br/>
<img src="22-锁_files/Image.png" type="image/png" data-filename="Image.png"/></p>
</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;">方案二：<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">读、写操作</strong>都采用<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">加锁</strong>的方式；<br/>
如果我们的一些业务场景不允许读取记录的旧版本，而是每次都必须去读取记录的最新版本，比方在银行存款的事务中，你需要先把账户的余额读出来，然后将其加上本次存款的数额，最后再写到数据库中。在将账户余额读取出来后，就不想让别的事务再访问该余额，直到本次存款事务执行完成，其他事务才可以访问账户的余额。这样在读取记录的时候也就需要对其进行加锁操作，这样也就意味着读操作和写操作也像写-写操作那样排队执行。<br/>
<img src="22-锁_files/Image [1].png" type="image/png" data-filename="Image.png"/></p>
</li>
</ul>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">很明显，采用MVCC方式的话，读-写操作彼此并不冲突，性能更高，采用加锁方式的话，读-写操作彼此需要排队执行，影响性能。一般情况下我们当然愿意采用MVCC来解决读-写操作并发执行的问题，但是业务在某些特殊情况下，要求必须采用加锁的方式执行，那也是没有办法的事。</p>
<h2 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 34px; border-bottom: 1px solid #dbdbdb; color: #333;">2 MySQL中的读操作</h2>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">对于MySQL的InnoDB存储引擎，读操作可以分为<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">快照读</strong>和<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">当前读</strong>，<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">当前读</strong>又可分为<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">锁定读</strong>和<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">写操作（insert、update、delete，因为写操作在执行写动作前，需要先读取需要进行写操作的记录）</strong>。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">那么<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">Repeatable Read</strong>隔离级别针对不同的读操作<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">解决幻读</strong>的技术方案如下：</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">快照读</strong>：基于<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">MVCC</strong>的多版本并发控制，原理是基于<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">版本链</strong>和<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">ReadView</strong>.</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">当前读</strong>：基于<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">锁</strong>的多版本并发控制，原理是<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">Next-key Locks（Record Locks和Gap Locks）</strong>.</li>
</ul>
<h3 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 27px; color: #333;">2-1 一致性读（Consistent Reads）</h3>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">事务利用<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">MVCC</strong>进行的读取操作称之为<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">一致性读</strong>，或者<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">一致性无锁读</strong>，有的地方也称之为<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">快照读</strong>。所有普通的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">SELECT语句（plain SELECT）<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">在Read Committed、Repeatable Read隔离级别下都是</strong>一致性读</strong>。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">一致性读</strong>并不会对表中的任何记录做<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">加锁操作</strong>，其他事务可以自由的对表中的记录做修改。</p>
<h3 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 27px; color: #333;">2-2 锁定读（Locking Reads）</h3>
<h3 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 27px; color: #333;">2-2-1 共享锁和独占锁</h3>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">在使用<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">加锁</strong>的方式解决问题时，由于既要允许<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">读-读</strong>情况不受影响，又要使<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">写-写、读-写或写-读</strong>情况中的操作相互阻塞，所以MySQL给锁进行了分类：</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">共享锁，Shared Locks，简称S锁</strong>：在事务要读取一条记录时，需要先获取该记录的S锁。</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">独占锁/排他锁，Exclusive Locks，简称X锁</strong>：在事务要修改一条记录时，需要先获取该记录的X锁。</li>
</ul>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">假如事务T1首先获取了一条记录的S锁之后，事务T2接着也要访问这条记录：</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">如果事务T2想要再获取一个记录的S锁，那么事务T2也会获得该锁，也就意味着事务T1和T2在该记录上同时持有S锁。</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">如果事务T2想要再获取一个记录的X锁，那么此操作会被阻塞，直到事务T1提交之后将S锁释放掉。</li>
</ul>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">如果事务T1首先获取了一条记录的X锁之后，那么不管事务T2接着想获取该记录的S锁还是X锁都会被阻塞，直到事务T1提交。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">所以说S锁和S锁是兼容的，S锁和X锁是不兼容的，X锁和X锁也是不兼容的：<br/>
<img src="22-锁_files/Image [2].png" type="image/png" data-filename="Image.png"/></p>
<h3 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 27px; color: #333;">2-2-2 锁定读的语句</h3>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">有时候在想读取记录时就获取记录的X锁，来禁止别的事务读写该记录，为此MySQL提出了两种比较特殊的SELECT语句格式：</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;">对读取的记录加<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">S锁</strong>：<br/>
<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">SELECT . . . LOCK IN SHARE MODE；</strong><br/>
也就是在普通的select语句后边加上<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">lock in share mode</strong>，如果当前事务执行了该语句，那么它为读取到的记录加<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">S锁</strong>，这也允许别的事务继续获取这些记录的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">S锁</strong>（比方说别的事务也使用SELECT ... LOCK IN SHARE MODE语句来读取这些记录），但是不能获取这些记录的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">X锁</strong>（比方说使用SELECT ... FOR UPDATE语句来读取这些记录，或者直接修改这些记录）。</p>
</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;">对读取的记录加<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">X锁</strong>：<br/>
<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">SELECT . . . FOR UPDATE；</strong><br/>
也就是在普通的select语句后边加<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">for update</strong>，如果当前事务执行了该语句，那么它会为读取到的记录加X锁，这样既不允许别的事务获取这些记录的S锁（比方说别的事务使用SELECT ... LOCK IN SHARE MODE语句来读取这些记录），也不允许获取这些记录的X锁（比方也说使用SELECT ... FOR UPDATE语句来读取这些记录，或者直接修改这些记录）。如果别的事务想要获取这些记录的S锁或者X锁，那么它们会阻塞，直到当前事务提交之后将这些记录上的X锁释放掉。</p>
</li>
</ul>
<h2 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 34px; border-bottom: 1px solid #dbdbdb; color: #333;">2-3 写操作</h2>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">平常所用到的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">写操作</strong>无非是<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">DELETE、UPDATE、INSERT</strong>这三种：</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">DELETE</strong><br/>
对一条记录做DELETE操作的过程其实是先在B+树中定位到这条记录的位置，然后获取一下这条记录的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">X锁</strong>，然后<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">再执行delete mark</strong>操作。这个定位待删除记录在B+树中位置的过程是一个获取X锁的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">锁定读</strong>。</p>
</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">UPDATE</strong><br/>
在对一条记录做UPDATE操作时分为三种情况：<br/>
<img src="22-锁_files/Image [3].png" type="image/png" data-filename="Image.png"/></p>
</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">INSERT</strong><br/>
一般情况下，新插入一条记录的操作并不加锁（在一些特殊情况下，insert操作也是会获取锁的），InnoDB通过<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">隐式锁</strong>来保护这条新插入的记录在本事务提交前不被别的事务访问。</p>
</li>
</ul>
<h2 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 34px; border-bottom: 1px solid #dbdbdb; color: #333;">3 多粒度锁</h2>
<h3 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 27px; color: #333;">3-1 表锁</h3>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">前面提到的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">锁</strong>都是针对记录的，也可以被称之为<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">行级锁</strong>或者<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">行锁</strong>，这个锁的粒度比较细；一个事务也可以在<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">表</strong>级别进行加锁，被称为<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">表级锁</strong>或者<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">表锁</strong>，对一个表加锁影响整个表中的记录，这个锁的粒度比较粗。给表加的锁也可以分为<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">共享锁（S锁）<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">和</strong>独占锁/排他锁（X锁）</strong>：</p>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">给表加<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">S锁</strong></h4>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">其他事务可以继续获得该表的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">S锁</strong>；</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">其他事务可以继续获得该表中的某些记录的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">S锁</strong>；</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">其他事务不可以继续获得该表的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">X锁</strong>；</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">其他事务不可以继续获得该表中的某些记录的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">X锁</strong>；</li>
</ul>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">给表加<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">X锁</strong></h4>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">其他事务不可以继续获得该表的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">S锁</strong>；</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">其他事务不可以继续获得该表中的某些记录的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">S锁</strong>；</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">其他事务不可以继续获得该表的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">X锁</strong>；</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">其他事务不可以继续获得该表中的某些记录的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">X锁</strong>；</li>
</ul>
<h3 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 27px; color: #333;">3-2 意向锁（Intention Locks）</h3>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">在对表整体上<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">S锁</strong>时，前提是表中没有记录被上<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">X锁</strong>；在对表整体上<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">X锁</strong>时，前提是表中没有记录被上<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">S锁和X锁</strong>。那怎么判断这个前提呢，InnoDB提出了一种锁，称之为<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">意向锁（Intention Locks）</strong>。</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">意向共享锁，Intention Shared Lock，简称IS锁</strong>。当事务准备在某条记录上加S锁时，需要先在表级加上一个<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">IS锁</strong>。</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">意向独占锁，Intention Exclusive Lock，简称IX锁</strong>。当事务准备在某条记录上加X锁时，需要先在表级别加上一个<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">IX锁</strong>。</li>
</ul>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">总结一下：<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">IS、IX锁是表级锁，它们的提出仅仅为了在之后加表级别的S锁和X锁时可以快速判断表中的记录是否被上锁，以避免用遍历的方式来查看表中有没有上锁的记录，也就是说其实IS锁和IX锁是兼容的，IX锁和IX锁是兼容的</strong>。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">表级别的各种锁的兼容性如下：<br/>
<img src="22-锁_files/Image [4].png" type="image/png" data-filename="Image.png"/></p>
<h2 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 34px; border-bottom: 1px solid #dbdbdb; color: #333;">4 MySQL中的行锁和表锁</h2>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">MySQL支持很多种存储引擎，不同存储引擎对锁的支持也不一样，重点讨论InnoDB存储引擎中的锁。</p>
<h3 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 27px; color: #333;">4-1 其他存储引擎中的锁</h3>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">对于<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">MyISAM、MEMORY、MERGE</strong>这些存储引擎来说，它们只支持<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">表级锁</strong>，而且这些引擎并不支持事务，所以使用这些存储引擎的锁一般都是针对当前会话来说的。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">因为使用MyISAM、MEMORY、MERGE这些存储引擎的表在同一时刻只允许一个会话对表进行写操作，所以这些存储引擎实际上最好用在只读，或者大部分都是读操作，或者单用户的情景下。另外，在<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">MyISAM</strong>存储引擎中有一个称之为<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">Concurrent Inserts</strong>的特性，支持在对MyISAM表读取时同时插入记录，这也可以提升插入速度。</p>
<h3 style="line-height: 160%; box-sizing: content-box; font-weight: 700; font-size: 27px; color: #333;">4-2 InnoDB存储引擎中的锁</h3>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">InnoDB存储引擎既支持表锁，也支持行锁。表锁实现简单，占用资源较少，不过粒度很粗，有时候你仅仅需要锁住几条记录，但使用表锁的话相当于为表中的所有记录都加锁，所以性能比较差。行锁粒度更细，可以实现更精准的并发控制。</p>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">4-2-1 InnoDB中的表级锁</h4>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">表级别的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">S锁、X锁</strong></h4>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">在对某个表执行select、insert、update、delete语句时，InnoDB存储引擎是不会为这个表添加表级别的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">S锁</strong>或者<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">X锁</strong>的。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">另外，在对某个表执行一些诸如ALTER TABLE、DROP TABLE这类的DDL语句时，其他事务对这个表并发执行诸如SELECT、INSERT、DELETE、UPDATE的语句会发生阻塞，同理，某个事务中对某个表执行SELECT、INSERT、DELETE、UPDATE语句时，在其他会话中对这个表执行DDL语句也会发生阻塞。这个过程是通过<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">server层</strong>使用的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">元数据锁（Metadata Locks，简称MDL）<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">来实现的，一般情况下也不会使用InnoDB存储引擎自己提供的表级别的</strong>S锁</strong>和<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">X锁</strong>。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">其实InnoDB存储引擎提供的表级S锁或者X锁是相当鸡肋，只会在一些特殊情况下，比方说崩溃恢复过程中用到。不过我们还是可以手动获取一下的，比方说在系统变量<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">autocommit = 0，innodb_table_locks = 1</strong>时，手动获取InnoDB存储引擎提供的表t的S锁或者X锁可以这么写：</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">a. LOCK TABLES t READ：InnoDB存储引擎会对表t加表级别的S锁。</strong><br/>
<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">b. LOCK TABLES t WRITE：InnoDB存储引擎会对表t加表级别的X锁。</strong></p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">不过请尽量避免在使用InnoDB存储引擎的表上使用<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">LOCK TABLES</strong>这样的手动锁表语句，它们并不会提供什么额外的保护，只是会降低并发能力而已。InnoDB的厉害之处还是实现了更细粒度的行锁，关于表级别的S锁和X锁大家了解一下就罢了。</p>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">表级别的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">IS锁、IX锁</strong></h4>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">当我们在对使用InnoDB存储引擎的表的某些记录加S锁之前，那就需要先在表级别加一个IS锁，当我们在对使用InnoDB存储引擎的表的某些记录加X锁之前，那就需要先在表级别加一个IX锁。IS锁和IX锁的使命只是为了后续在加表级别的S锁和X锁时判断表中是否有已经被加锁的记录，以避免用遍历的方式来查看表中有没有上锁的记录。</p>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">表级别的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">AUTO-INC锁</strong></h4>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">在使用MySQL过程中，可以为表的某个列添加AUTO_INCREMENT属性，之后在插入记录时，可以不指定该列的值，系统会自动为它赋上递增的值，系统实现这种自动给AUTO_INCREMENT修饰的列递增赋值的原理主要是两个：</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;">采用<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">AUTO-INC锁</strong>，就是在执行插入语句时就在表级别加一个<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">AUTO-INC锁</strong>，然后为每条待插入记录的AUTO_INCREMENT修饰的列分配递增的值，<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">在该语句执行结束后，再把AUTO-INC锁释放掉</strong>。这样一个事务在持有AUTO-INC锁的过程中，其他事务的插入语句都要被阻塞，可以保证一个语句中分配的递增值是连续的。<br/>
<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">如果插入语句在执行前不可以确定具体要插入多少条记录（无法预计即将插入记录的数量），比方说使用INSERT ... SELECT、REPLACE ... SELECT或者LOAD DATA这种插入语句，一般是使用AUTO-INC锁为AUTO_INCREMENT修饰的列生成对应的值。</strong><br/>
需要注意一下的是，这个<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">AUTO-INC锁的作用范围只是单个插入语句</strong>，<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">插入语句执行完成后，这个锁就被释放了</strong>，跟我们之前介绍的锁在事务结束时释放是不一样的。</p>
</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;">采用一个<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">轻量级的锁</strong>，在为插入语句生成AUTO_INCREMENT修饰的列的值时获取一下这个轻量级锁，<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">然后生成本次插入语句需要用到的AUTO_INCREMENT列的值之后，就把该轻量级锁释放掉，并不需要等到整个插入语句执行完才释放锁</strong>。<br/>
如果我们的插入语句在执行前就可以确定具体要插入多少条记录，比方说我们上边举的关于表t的例子中，在语句执行前就可以确定要插入2条记录，那么一般采用轻量级锁的方式对AUTO_INCREMENT修饰的列进行赋值。这种方式可以避免锁定表，可以提升插入性能。</p>
</li>
</ul>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">InnoDB提供了一个称之为<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">innodb_autoinc_lock_mode</strong>的系统变量来控制到底使用上述两种方式中的哪种来为AUTO_INCREMENT修饰的列进行赋值：</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">当innodb_autoinc_lock_mode值为0时，一律采用AUTO-INC锁；</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">当innodb_autoinc_lock_mode值为2时，一律采用轻量级锁；</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">当innodb_autoinc_lock_mode值为1时，两种方式混着来（也就是在插入记录数量确定时采用轻量级锁，不确定时使用AUTO-INC锁）。</li>
</ul>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">不过当innodb_autoinc_lock_mode值为2时，可能会造成不同事务中的插入语句为AUTO_INCREMENT修饰的列生成的值是交叉的，在有主从复制的场景中是不安全的</strong>。</p>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">InnoDB中的行级索</h4>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">行锁</strong>，也称为<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">记录锁</strong>，顾名思义就是在记录上加的锁。行锁可以分为很多种类型。换句话说即使对同一条记录加行锁，如果类型不同，起到的功效也是不同的。为了故事的顺利发展，我们还是先将之前唠叨MVCC时用到的表抄一遍：<br/>
<img src="22-锁_files/Image [5].png" type="image/png" data-filename="Image.png"/></p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">把hero表中的聚簇索引的示意图画一下：<br/>
<img src="22-锁_files/1 [4].jpg" type="image/jpeg" data-filename="1.jpg"/></p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">下面来看一下行锁类型：</p>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">Records Locks</h4>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">前边提到的记录锁就是这种类型，也就是仅仅把一条记录锁上，官方的类型名称为：<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">LOCK_REC_NOT_GAP</strong>。比方说我们把number值为8的那条记录加一个正经记录锁的示意图如下：<br/>
<img src="22-锁_files/1 [5].jpg" type="image/jpeg" data-filename="1.jpg"/></p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">Records Locks</strong>是有S锁和X锁之分的，当一个事务获取了一条记录的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">S型Records Locks</strong>记录锁后，其他事务也可以继续获取该记录的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">S型Records Locks</strong>记录锁，但不可以继续获取<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">X型Records Locks</strong>记录锁；当一个事务获取了一条记录的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">X型Records Locks</strong>记录锁后，其他事务既不可以继续获取该记录的<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">S型Records Locks</strong>记录锁，也不可以继续获取<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">X型Records Locks</strong>记录锁；</p>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">Gap Locks</h4>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">MySQL在REPEATABLE READ隔离级别下是可以解决幻读问题的，解决方案有两种，可以使用MVCC方案解决，也可以采用加锁方案解决。但是在使用加锁方案解决时有个大问题，就是事务在第一次执行读取操作时，那些幻影记录尚不存在，无法给这些幻影记录加上正经记录锁。InnoDB们提出了一种称之为<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">Gap Locks</strong>的锁，官方的类型名称为：<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">LOCK_GAP</strong>，也可以简称为<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">gap锁</strong>。比方说我们把number值为8的那条记录加一个gap锁的示意图如下：<br/>
<img src="22-锁_files/1 [6].jpg" type="image/jpeg" data-filename="1.jpg"/></p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">如图中为number值为8的记录加了gap锁，意味着不允许别的事务在number值为8的记录前边的间隙插入新记录，其实就是number列的值(3, 8)这个区间的新记录是不允许立即插入的。比方说有另外一个事务再想插入一条number值为4的新记录，它定位到该条新记录的下一条记录的number值为8，而这条记录上又有一个gap锁，所以就会阻塞插入操作，直到拥有这个gap锁的事务提交了之后，number列的值在区间(3, 8)中的新记录才可以被插入。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;"><strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">这个gap锁的提出仅仅是为了防止插入幻影记录而提出的</strong>，虽然有共享gap锁和独占gap锁这样的说法，但是它们起到的作用都是相同的。而且如果你对一条记录加了gap锁（不论是共享gap锁还是独占gap锁），并不会限制其他事务对这条记录加正经记录锁或者继续加gap锁，再强调一遍，gap锁的作用仅仅是为了防止插入幻影记录的而已。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">不知道大家发现了一个问题没，给一条记录加了gap锁只是不允许其他事务往这条记录前边的间隙插入新记录，那对于最后一条记录之后的间隙，也就是hero表中number值为20的记录之后的间隙该咋办呢？也就是说给哪条记录加gap锁才能阻止其他事务插入number值在(20, +∞)这个区间的新记录呢？这时候应该想起我们在前边唠叨数据页时介绍的两条伪记录了：</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">Infimum记录，表示该页面中最小的记录；</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">Supermum记录，表示该页面中最大的记录；</li>
</ul>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">为了实现阻止其他事务插入number值在(20, +∞)这个区间的新记录，给索引中的最后一条记录，也就是number值为20的那条记录所在页面的Supremum记录加上一个gap锁，画个图就是这样：<br/>
<img src="22-锁_files/1 [7].jpg" type="image/jpeg" data-filename="1.jpg"/><br/>
这样就可以阻止其他事务插入number值在(20, +∞)这个区间的新记录。为了大家理解方便，之后的索引示意图中都会把这个Supremum记录画出来。</p>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">Next-Key Locks</h4>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">有时候既想锁住某条记录，又想阻止其他事务在该记录前边的间隙插入新记录，InnoDB就提出了一种称之为<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">Next-Key Locks</strong>的锁，官方的类型名称为：<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">LOCK_ORDINARY</strong>，也可以简称为next-key锁。比方说把number值为8的那条记录加一个next-key锁的示意图如下：<br/>
<img src="22-锁_files/1 [8].jpg" type="image/jpeg" data-filename="1.jpg"/></p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">next-key锁的本质就是一个record锁和一个gap锁的合体，它既能保护该条记录，又能阻止别的事务将新记录插入被保护记录前边的间隙。</p>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">Insert Intention Locks</h4>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">一个事务在插入一条记录时需要判断一下插入位置是不是被别的事务加了所谓的gap锁，如果有的话，插入操作需要等待，直到拥有gap锁的那个事务提交。但是InnoDB规定事务在等待的时候也需要在内存中生成一个<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">锁结构</strong>，表明有事务想在某个<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">间隙</strong>中插入新记录，但是现在在等待，这种类型的锁称为<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">Insert Intention Locks</strong>，官方的类型名称为：<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">LOCK_INSERT_INTENTION</strong>，也可以称为<strong style="line-height: 160%; box-sizing: content-box; font-weight: 700;">插入意向锁</strong>。</p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">比方说我们把number值为8的那条记录加一个插入意向锁的示意图如下：<br/>
<img src="22-锁_files/1 [9].jpg" type="image/jpeg" data-filename="1.jpg"/></p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">为了让大家彻底理解这个插入意向锁的功能，我们还是举个例子然后画个图表示一下。比方说现在T1为number值为8的记录加了一个gap锁，然后T2和T3分别想向hero表中插入number值分别为4、5的两条记录，所以现在为number值为8的记录加的锁的示意图就如下所示：<br/>
<img src="22-锁_files/1 [10].jpg" type="image/jpeg" data-filename="1.jpg"/></p>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">从图中可以看到，由于T1持有gap锁，所以T2和T3需要生成一个插入意向锁的锁结构并且处于等待状态。当T1提交后会把它获取到的锁都释放掉，这样T2和T3就能获取到对应的插入意向锁了（本质上就是把插入意向锁对应锁结构的is_waiting属性改为false），T2和T3之间也并不会相互阻塞，它们可以同时获取到number值为8的插入意向锁，然后执行插入操作。事实上插入意向锁并不会阻止别的事务继续获取该记录上任何类型的锁（插入意向锁就是这么鸡肋）。</p>
<h4 style="line-height: 160%; box-sizing: content-box; font-size: 20px; color: #333;">隐式锁</h4>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">前边说一个事务在执行INSERT操作时，如果即将插入的间隙已经被其他事务加了gap锁，那么本次INSERT操作会阻塞，并且当前事务会在该间隙上加一个插入意向锁，否则一般情况下INSERT操作是不加锁的。那如果一个事务首先插入了一条记录（此时并没有与该记录关联的锁结构），然后另一个事务：</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;">立即使用SELECT ... LOCK IN SHARE MODE语句读取这条事务，也就是在要获取这条记录的S锁，或者使用SELECT ... FOR UPDATE语句读取这条事务或者直接修改这条记录，也就是要获取这条记录的X锁，该咋办？<br/>
如果允许这种情况的发生，那么可能产生脏读问题。</p>
</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">
<p style="line-height: 160%; box-sizing: content-box; color: #333; margin: 0;">立即修改这条记录，也就是要获取这条记录的X锁，该咋办？<br/>
如果允许这种情况的发生，那么可能产生脏写问题。</p>
</li>
</ul>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">这时候我们前边唠叨了很多遍的事务id又要起作用了。我们把聚簇索引和二级索引中的记录分开看一下：</p>
<ul style="line-height: 160%; box-sizing: content-box; display: block; list-style-type: disc; padding-left: 30px; margin: 6px 0 10px; color: #333;">
<li style="line-height: 160%; box-sizing: content-box; position: relative;">情景一：对于聚簇索引记录来说，有一个trx_id隐藏列，该隐藏列记录着最后改动该记录的事务id。那么如果在当前事务中新插入一条聚簇索引记录后，该记录的trx_id隐藏列代表的的就是当前事务的事务id，如果其他事务此时想对该记录添加S锁或者X锁时，首先会看一下该记录的trx_id隐藏列代表的事务是否是当前的活跃事务，如果是的话，那么就帮助当前事务创建一个X锁（也就是为当前事务创建一个锁结构，is_waiting属性是false），然后自己进入等待状态（也就是为自己也创建一个锁结构，is_waiting属性是true）。</li>
<li style="line-height: 160%; box-sizing: content-box; position: relative;">情景二：对于二级索引记录来说，本身并没有trx_id隐藏列，但是在二级索引页面的Page Header部分有一个PAGE_MAX_TRX_ID属性，该属性代表对该页面做改动的最大的事务id，如果PAGE_MAX_TRX_ID属性值小于当前最小的活跃事务id，那么说明对该页面做修改的事务都已经提交了，否则就需要在页面中定位到对应的二级索引记录，然后回表找到它对应的聚簇索引记录，然后再重复情景一的做法。</li>
</ul>
<p style="line-height: 160%; box-sizing: content-box; margin: 10px 0; color: #333;">通过上边的叙述我们知道，一个事务对新插入的记录可以不显式的加锁（生成一个锁结构），但是由于事务id这个牛逼的东东的存在，相当于加了一个隐式锁。别的事务在对这条记录加S锁或者X锁时，由于隐式锁的存在，会先帮助当前事务生成一个锁结构，然后自己再生成一个锁结构后进入等待状态。</p>
</div><center style="display:none !important;visibility:collapse !important;height:0 !important;white-space:nowrap;width:100%;overflow:hidden">%23%23%201%20%E8%A7%A3%E5%86%B3%E5%B9%B6%E5%8F%91%E4%BA%8B%E5%8A%A1%E5%B8%A6%E6%9D%A5%E7%9A%84%E9%97%AE%E9%A2%98%EF%BC%9A%E4%B8%A4%E7%A7%8D%E8%A7%A3%E5%86%B3%E6%96%B9%E5%BC%8F%0A%0A%E4%B8%8A%E4%B8%80%E7%AB%A0%E8%AE%B2%E8%BF%B0%E4%BA%86%E4%BA%8B%E5%8A%A1%E5%B9%B6%E5%8F%91%E6%89%A7%E8%A1%8C%E6%97%B6%E5%8F%AF%E8%83%BD%E5%B8%A6%E6%9D%A5%E7%9A%84%E5%90%84%E7%A7%8D%E9%97%AE%E9%A2%98%EF%BC%8C%E5%B9%B6%E5%8F%91%E4%BA%8B%E5%8A%A1%E8%AE%BF%E9%97%AE%E7%9B%B8%E5%90%8C%E8%AE%B0%E5%BD%95%E7%9A%84%E6%83%85%E5%86%B5%E5%A4%A7%E8%87%B4%E5%8F%AF%E4%BB%A5%E5%88%92%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BF%99%E4%B8%AA%E6%8E%92%E9%98%9F%E7%9A%84%E8%BF%87%E7%A8%8B%E5%85%B6%E5%AE%9E%E6%98%AF%E9%80%9A%E8%BF%87**%E9%94%81**%E6%9D%A5%E5%AE%9E%E7%8E%B0%E7%9A%84%E3%80%82%0A%0A%E8%BF%99%E4%B8%AA**%E9%94%81**%E5%85%B6%E5%AE%9E%E6%98%AF%E4%B8%80%E4%B8%AA%E5%86%85%E5%AD%98%E4%B8%AD%E7%9A%84%E7%BB%93%E6%9E%84%EF%BC%8C%E5%9C%A8%E4%BA%8B%E5%8A%A1%E6%89%A7%E8%A1%8C%E5%89%8D%E6%9C%AC%E6%9D%A5%E6%98%AF%E6%B2%A1%E6%9C%89%E9%94%81%E7%9A%84%EF%BC%8C%E4%B9%9F%E5%B0%B1%E6%98%AF%E8%AF%B4%E4%B8%80%E5%BC%80%E5%A7%8B%E6%98%AF%E6%B2%A1%E6%9C%89**%E9%94%81%E7%BB%93%E6%9E%84**%E5%92%8C%E8%AE%B0%E5%BD%95%E8%BF%9B%E8%A1%8C%E5%85%B3%E8%81%94%E7%9A%84%EF%BC%8C%E5%A6%82%E5%9B%BE%EF%BC%9A%0A!%5B80d7045f6b7dee2cb78ed0b6efa082cb.jpeg%5D(en-resource%3A%2F%2Fdatabase%2F998%3A1)%0A%0A%E5%BD%93%E4%B8%80%E4%B8%AA%E4%BA%8B%E5%8A%A1%E6%83%B3%E5%AF%B9%E8%BF%99%E6%9D%A1%E8%AE%B0%E5%BD%95%E5%81%9A%E6%94%B9%E5%8A%A8%E6%97%B6%EF%BC%8C%E9%A6%96%E5%85%88%E4%BC%9A%E7%9C%8B%E7%9C%8B%E5%86%85%E5%AD%98%E4%B8%AD%E6%9C%89%E6%B2%A1%E6%9C%89%E4%B8%8E%E8%BF%99%E6%9D%A1%E8%AE%B0%E5%BD%95%E5%85%B3%E8%81%94%E7%9A%84**%E9%94%81%E7%BB%93%E6%9E%84**%EF%BC%8C%E5%BD%93%E6%B2%A1%E6%9C%89%E7%9A%84%E6%97%B6%E5%80%99%E5%B0%B1%E4%BC%9A%E5%9C%A8%E5%86%85%E5%AD%98%E4%B8%AD%E7%94%9F%E6%88%90%E4%B8%80%E4%B8%AA**%E9%94%81%E7%BB%93%E6%9E%84**%E4%B8%8E%E4%B9%8B%E5%85%B3%E8%81%94%E3%80%82%E6%AF%94%E6%96%B9%E8%AF%B4%E4%BA%8B%E5%8A%A1T1%E8%A6%81%E5%AF%B9%E8%BF%99%E6%9D%A1%E8%AE%B0%E5%BD%95%E5%81%9A%E6%94%B9%E5%8A%A8%EF%BC%8C%E5%B0%B1%E9%9C%80%E8%A6%81%E7%94%9F%E6%88%90%E4%B8%80%E4%B8%AA**%E9%94%81%E7%BB%93%E6%9E%84**%E4%B8%8E%E4%B9%8B%E5%85%B3%E8%81%94%EF%BC%9A%0A!%5Bcd7e009c552b868361b5be3064ada66a.jpeg%5D(en-resource%3A%2F%2Fdatabase%2F999%3A1)%0A%0A%0A%E5%85%B6%E5%AE%9E%E5%9C%A8%E9%94%81%E7%BB%93%E6%9E%84%E9%87%8C%E6%9C%89%E5%BE%88%E5%A4%9A%E4%BF%A1%E6%81%AF%EF%BC%8C%E4%B8%8D%E8%BF%87%E4%B8%BA%E4%BA%86%E7%AE%80%E5%8C%96%E7%90%86%E8%A7%A3%EF%BC%8C%E7%8E%B0%E5%9C%A8%E5%8F%AA%E6%8A%8A%E4%B8%A4%E4%B8%AA%E6%AF%94%E8%BE%83%E9%87%8D%E8%A6%81%E7%9A%84%E5%B1%9E%E6%80%A7%E6%8B%BF%E4%BA%86%E5%87%BA%E6%9D%A5%EF%BC%9A%0A%0A*%20**trx%E4%BF%A1%E6%81%AF**%EF%BC%9A%E4%BB%A3%E8%A1%A8%E8%BF%99%E4%B8%AA%E9%94%81%E7%BB%93%E6%9E%84%E6%98%AF%E5%93%AA%E4%B8%AA%E4%BA%8B%E5%8A%A1%E7%94%9F%E6%88%90%E7%9A%84%EF%BC%9B%0A*%20**is_wa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AF%A2%E8%AF%AD%E5%8F%A5%E5%8F%AA%E8%83%BD%E8%AF%BB%E5%88%B0%E5%9C%A8%E7%94%9F%E6%88%90ReadView%E4%B9%8B%E5%89%8D%E5%B7%B2%E6%8F%90%E4%BA%A4%E4%BA%8B%E5%8A%A1%E6%89%80%E5%81%9A%E7%9A%84%E6%9B%B4%E6%94%B9%EF%BC%8C%E5%9C%A8%E7%94%9F%E6%88%90ReadView%E4%B9%8B%E5%89%8D%E6%9C%AA%E6%8F%90%E4%BA%A4%E7%9A%84%E4%BA%8B%E5%8A%A1%E6%88%96%E8%80%85%E4%B9%8B%E5%90%8E%E6%89%8D%E5%BC%80%E5%90%AF%E7%9A%84%E4%BA%8B%E5%8A%A1%E6%89%80%E5%81%9A%E7%9A%84%E6%9B%B4%E6%94%B9%E6%98%AF%E7%9C%8B%E4%B8%8D%E5%88%B0%E7%9A%84%E3%80%82%E8%80%8C%E5%86%99%E6%93%8D%E4%BD%9C%E8%82%AF%E5%AE%9A%E9%92%88%E5%AF%B9%E7%9A%84%E6%98%AF%E6%9C%80%E6%96%B0%E7%89%88%E6%9C%AC%E7%9A%84%E8%AE%B0%E5%BD%95%EF%BC%8C%E8%AF%BB%E8%AE%B0%E5%BD%95%E7%9A%84%E5%8E%86%E5%8F%B2%E7%89%88%E6%9C%AC%E5%92%8C%E6%94%B9%E5%8A%A8%E8%AE%B0%E5%BD%95%E7%9A%84%E6%9C%80%E6%96%B0%E7%89%88%E6%9C%AC%E6%9C%AC%E8%BA%AB%E5%B9%B6%E4%B8%8D%E5%86%B2%E7%AA%81%EF%BC%8C%E4%B9%9F%E5%B0%B1%E6%98%AF%E9%87%87%E7%94%A8MVCC%E6%97%B6%EF%BC%8C%E8%AF%BB-%E5%86%99%E6%93%8D%E4%BD%9C%E5%B9%B6%E4%B8%8D%E5%86%B2%E7%AA%81%E3%80%82%0A!%5B22f13270535d66fb51276e8b7d8d4ce3.png%5D(en-resource%3A%2F%2Fdatabase%2F1000%3A1)%0A%0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%BA**%E5%BF%AB%E7%85%A7%E8%AF%BB**%E5%92%8C**%E5%BD%93%E5%89%8D%E8%AF%BB**%EF%BC%8C**%E5%BD%93%E5%89%8D%E8%AF%BB**%E5%8F%88%E5%8F%AF%E5%88%86%E4%B8%BA**%E9%94%81%E5%AE%9A%E8%AF%BB**%E5%92%8C**%E5%86%99%E6%93%8D%E4%BD%9C%EF%BC%88insert%E3%80%81update%E3%80%81delete%EF%BC%8C%E5%9B%A0%E4%B8%BA%E5%86%99%E6%93%8D%E4%BD%9C%E5%9C%A8%E6%89%A7%E8%A1%8C%E5%86%99%E5%8A%A8%E4%BD%9C%E5%89%8D%EF%BC%8C%E9%9C%80%E8%A6%81%E5%85%88%E8%AF%BB%E5%8F%96%E9%9C%80%E8%A6%81%E8%BF%9B%E8%A1%8C%E5%86%99%E6%93%8D%E4%BD%9C%E7%9A%84%E8%AE%B0%E5%BD%95%EF%BC%89**%E3%80%82%0A%0A%E9%82%A3%E4%B9%88**Repeatable%20Read**%E9%9A%94%E7%A6%BB%E7%BA%A7%E5%88%AB%E9%92%88%E5%AF%B9%E4%B8%8D%E5%90%8C%E7%9A%84%E8%AF%BB%E6%93%8D%E4%BD%9C**%E8%A7%A3%E5%86%B3%E5%B9%BB%E8%AF%BB**%E7%9A%84%E6%8A%80%E6%9C%AF%E6%96%B9%E6%A1%88%E5%A6%82%E4%B8%8B%EF%BC%9A%0A%0A%0A*%20**%E5%BF%AB%E7%85%A7%E8%AF%BB**%EF%BC%9A%E5%9F%BA%E4%BA%8E**MVCC**%E7%9A%84%E5%A4%9A%E7%89%88%E6%9C%AC%E5%B9%B6%E5%8F%91%E6%8E%A7%E5%88%B6%EF%BC%8C%E5%8E%9F%E7%90%86%E6%98%AF%E5%9F%BA%E4%BA%8E**%E7%89%88%E6%9C%AC%E9%93%BE**%E5%92%8C**ReadView**.%0A*%20**%E5%BD%93%E5%89%8D%E8%AF%BB**%EF%BC%9A%E5%9F%BA%E4%BA%8E**%E9%94%81**%E7%9A%84%E5%A4%9A%E7%89%88%E6%9C%AC%E5%B9%B6%E5%8F%91%E6%8E%A7%E5%88%B6%EF%BC%8C%E5%8E%9F%E7%90%86%E6%98%AF**Next-key%20Locks%EF%BC%88Record%20Locks%E5%92%8CGap%20Locks%EF%BC%89**.%0A%0A%23%23%23%202-1%20%E4%B8%80%E8%87%B4%E6%80%A7%E8%AF%BB%EF%BC%88Consistent%20Reads%EF%BC%89%0A%E4%BA%8B%E5%8A%A1%E5%88%A9%E7%94%A8**MVCC**%E8%BF%9B%E8%A1%8C%E7%9A%84%E8%AF%BB%E5%8F%96%E6%93%8D%E4%BD%9C%E7%A7%B0%E4%B9%8B%E4%B8%BA**%E4%B8%80%E8%87%B4%E6%80%A7%E8%AF%BB**%EF%BC%8C%E6%88%96%E8%80%85**%E4%B8%80%E8%87%B4%E6%80%A7%E6%97%A0%E9%94%81%E8%AF%BB**%EF%BC%8C%E6%9C%89%E7%9A%84%E5%9C%B0%E6%96%B9%E4%B9%9F%E7%A7%B0%E4%B9%8B%E4%B8%BA**%E5%BF%AB%E7%85%A7%E8%AF%BB**%E3%80%82%E6%89%80%E6%9C%89%E6%99%AE%E9%80%9A%E7%9A%84**SELECT%E8%AF%AD%E5%8F%A5%EF%BC%88plain%20SELECT%EF%BC%89**%E5%9C%A8Read%20Committed%E3%80%81Repeatable%20Read%E9%9A%94%E7%A6%BB%E7%BA%A7%E5%88%AB%E4%B8%8B%E9%83%BD%E6%98%AF**%E4%B8%80%E8%87%B4%E6%80%A7%E8%AF%BB**%E3%80%82%0A%0A**%E4%B8%80%E8%87%B4%E6%80%A7%E8%AF%BB**%E5%B9%B6%E4%B8%8D%E4%BC%9A%E5%AF%B9%E8%A1%A8%E4%B8%AD%E7%9A%84%E4%BB%BB%E4%BD%95%E8%AE%B0%E5%BD%95%E5%81%9A**%E5%8A%A0%E9%94%81%E6%93%8D%E4%BD%9C**%EF%BC%8C%E5%85%B6%E4%BB%96%E4%BA%8B%E5%8A%A1%E5%8F%AF%E4%BB%A5%E8%87%AA%E7%94%B1%E7%9A%84%E5%AF%B9%E8%A1%A8%E4%B8%AD%E7%9A%84%E8%AE%B0%E5%BD%95%E5%81%9A%E4%BF%AE%E6%94%B9%E3%80%82%0A%0A%23%23%23%202-2%20%E9%94%81%E5%AE%9A%E8%AF%BB%EF%BC%88Locking%20Reads%EF%BC%89%0A%0A%23%23%23%202-2-1%20%E5%85%B1%E4%BA%AB%E9%94%81%E5%92%8C%E7%8B%AC%E5%8D%A0%E9%94%81%0A%0A%E5%9C%A8%E4%BD%BF%E7%94%A8**%E5%8A%A0%E9%94%81**%E7%9A%84%E6%96%B9%E5%BC%8F%E8%A7%A3%E5%86%B3%E9%97%AE%E9%A2%98%E6%97%B6%EF%BC%8C%E7%94%B1%E4%BA%8E%E6%97%A2%E8%A6%81%E5%85%81%E8%AE%B8**%E8%AF%BB-%E8%AF%BB**%E6%83%85%E5%86%B5%E4%B8%8D%E5%8F%97%E5%BD%B1%E5%93%8D%EF%BC%8C%E5%8F%88%E8%A6%81%E4%BD%BF**%E5%86%99-%E5%86%99%E3%80%81%E8%AF%BB-%E5%86%99%E6%88%96%E5%86%99-%E8%AF%BB**%E6%83%85%E5%86%B5%E4%B8%AD%E7%9A%84%E6%93%8D%E4%BD%9C%E7%9B%B8%E4%BA%92%E9%98%BB%E5%A1%9E%EF%BC%8C%E6%89%80%E4%BB%A5MySQL%E7%BB%99%E9%94%81%E8%BF%9B%E8%A1%8C%E4%BA%86%E5%88%86%E7%B1%BB%EF%BC%9A%0A%0A*%20**%E5%85%B1%E4%BA%AB%E9%94%81%EF%BC%8CShared%20Locks%EF%BC%8C%E7%AE%80%E7%A7%B0S%E9%94%81**%EF%BC%9A%E5%9C%A8%E4%BA%8B%E5%8A%A1%E8%A6%81%E8%AF%BB%E5%8F%96%E4%B8%80%E6%9D%A1%E8%AE%B0%E5%BD%95%E6%97%B6%EF%BC%8C%E9%9C%80%E8%A6%81%E5%85%88%E8%8E%B7%E5%8F%96%E8%A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E%B9%E7%9A%84%EF%BC%9A%0A!%5B78edf26b97cf65d92283d98c5c12fb19.png%5D(en-resource%3A%2F%2Fdatabase%2F1002%3A1)%0A%0A%23%23%23%202-2-2%20%E9%94%81%E5%AE%9A%E8%AF%BB%E7%9A%84%E8%AF%AD%E5%8F%A5%0A%0A%E6%9C%89%E6%97%B6%E5%80%99%E5%9C%A8%E6%83%B3%E8%AF%BB%E5%8F%96%E8%AE%B0%E5%BD%95%E6%97%B6%E5%B0%B1%E8%8E%B7%E5%8F%96%E8%AE%B0%E5%BD%95%E7%9A%84X%E9%94%81%EF%BC%8C%E6%9D%A5%E7%A6%81%E6%AD%A2%E5%88%AB%E7%9A%84%E4%BA%8B%E5%8A%A1%E8%AF%BB%E5%86%99%E8%AF%A5%E8%AE%B0%E5%BD%95%EF%BC%8C%E4%B8%BA%E6%AD%A4MySQL%E6%8F%90%E5%87%BA%E4%BA%86%E4%B8%A4%E7%A7%8D%E6%AF%94%E8%BE%83%E7%89%B9%E6%AE%8A%E7%9A%84SELECT%E8%AF%AD%E5%8F%A5%E6%A0%BC%E5%BC%8F%EF%BC%9A%0A%0A*%20%E5%AF%B9%E8%AF%BB%E5%8F%96%E7%9A%84%E8%AE%B0%E5%BD%95%E5%8A%A0**S%E9%94%81**%EF%BC%9A%0A**SELECT%20.%20.%20.%20LOCK%20IN%20SHARE%20MODE%EF%BC%9B**%0A%E4%B9%9F%E5%B0%B1%E6%98%AF%E5%9C%A8%E6%99%AE%E9%80%9A%E7%9A%84select%E8%AF%AD%E5%8F%A5%E5%90%8E%E8%BE%B9%E5%8A%A0%E4%B8%8A**lock%20in%20share%20mode**%EF%BC%8C%E5%A6%82%E6%9E%9C%E5%BD%93%E5%89%8D%E4%BA%8B%E5%8A%A1%E6%89%A7%E8%A1%8C%E4%BA%86%E8%AF%A5%E8%AF%AD%E5%8F%A5%EF%BC%8C%E9%82%A3%E4%B9%88%E5%AE%83%E4%B8%BA%E8%AF%BB%E5%8F%96%E5%88%B0%E7%9A%84%E8%AE%B0%E5%BD%95%E5%8A%A0**S%E9%94%81**%EF%BC%8C%E8%BF%99%E4%B9%9F%E5%85%81%E8%AE%B8%E5%88%AB%E7%9A%84%E4%BA%8B%E5%8A%A1%E7%BB%A7%E7%BB%AD%E8%8E%B7%E5%8F%96%E8%BF%99%E4%BA%9B%E8%AE%B0%E5%BD%95%E7%9A%84**S%E9%94%81**%EF%BC%88%E6%AF%94%E6%96%B9%E8%AF%B4%E5%88%AB%E7%9A%84%E4%BA%8B%E5%8A%A1%E4%B9%9F%E4%BD%BF%E7%94%A8SELECT%20...%20LOCK%20IN%20SHARE%20MODE%E8%AF%AD%E5%8F%A5%E6%9D%A5%E8%AF%BB%E5%8F%96%E8%BF%99%E4%BA%9B%E8%AE%B0%E5%BD%95%EF%BC%89%EF%BC%8C%E4%BD%86%E6%98%AF%E4%B8%8D%E8%83%BD%E8%8E%B7%E5%8F%96%E8%BF%99%E4%BA%9B%E8%AE%B0%E5%BD%95%E7%9A%84**X%E9%94%81**%EF%BC%88%E6%AF%94%E6%96%B9%E8%AF%B4%E4%BD%BF%E7%94%A8SELECT%20...%20FOR%20UPDATE%E8%AF%AD%E5%8F%A5%E6%9D%A5%E8%AF%BB%E5%8F%96%E8%BF%99%E4%BA%9B%E8%AE%B0%E5%BD%95%EF%BC%8C%E6%88%96%E8%80%85%E7%9B%B4%E6%8E%A5%E4%BF%AE%E6%94%B9%E8%BF%99%E4%BA%9B%E8%AE%B0%E5%BD%95%EF%BC%89%E3%80%82%0A%0A*%20%E5%AF%B9%E8%AF%BB%E5%8F%96%E7%9A%84%E8%AE%B0%E5%BD%95%E5%8A%A0**X%E9%94%81**%EF%BC%9A%0A**SELECT%20.%20.%20.%20FOR%20UPDATE%EF%BC%9B**%0A%E4%B9%9F%E5%B0%B1%E6%98%AF%E5%9C%A8%E6%99%AE%E9%80%9A%E7%9A%84select%E8%AF%AD%E5%8F%A5%E5%90%8E%E8%BE%B9%E5%8A%A0**for%20update**%EF%BC%8C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E%B7%E5%8F%96%E8%BF%99%E4%BA%9B%E8%AE%B0%E5%BD%95%E7%9A%84S%E9%94%81%E6%88%96%E8%80%85X%E9%94%81%EF%BC%8C%E9%82%A3%E4%B9%88%E5%AE%83%E4%BB%AC%E4%BC%9A%E9%98%BB%E5%A1%9E%EF%BC%8C%E7%9B%B4%E5%88%B0%E5%BD%93%E5%89%8D%E4%BA%8B%E5%8A%A1%E6%8F%90%E4%BA%A4%E4%B9%8B%E5%90%8E%E5%B0%86%E8%BF%99%E4%BA%9B%E8%AE%B0%E5%BD%95%E4%B8%8A%E7%9A%84X%E9%94%81%E9%87%8A%E6%94%BE%E6%8E%89%E3%80%82%0A%0A%23%23%202-3%20%E5%86%99%E6%93%8D%E4%BD%9C%0A%0A%E5%B9%B3%E5%B8%B8%E6%89%80%E7%94%A8%E5%88%B0%E7%9A%84**%E5%86%99%E6%93%8D%E4%BD%9C**%E6%97%A0%E9%9D%9E%E6%98%AF**DELETE%E3%80%81UPDATE%E3%80%81INSERT**%E8%BF%99%E4%B8%89%E7%A7%8D%EF%BC%9A%0A%0A*%20**DELETE**%0A%E5%AF%B9%E4%B8%80%E6%9D%A1%E8%AE%B0%E5%BD%95%E5%81%9ADELETE%E6%93%8D%E4%BD%9C%E7%9A%84%E8%BF%87%E7%A8%8B%E5%85%B6%E5%AE%9E%E6%98%AF%E5%85%88%E5%9C%A8B%2B%E6%A0%91%E4%B8%AD%E5%AE%9A%E4%BD%8D%E5%88%B0%E8%BF%99%E6%9D%A1%E8%AE%B0%E5%BD%95%E7%9A%84%E4%BD%8D%E7%BD%AE%EF%BC%8C%E7%84%B6%E5%90%8E%E8%8E%B7%E5%8F%96%E4%B8%80%E4%B8%8B%E8%BF%99%E6%9D%A1%E8%AE%B0%E5%BD%95%E7%9A%84**X%E9%94%81**%EF%BC%8C%E7%84%B6%E5%90%8E**%E5%86%8D%E6%89%A7%E8%A1%8Cdelete%20mark**%E6%93%8D%E4%BD%9C%E3%80%82%E8%BF%99%E4%B8%AA%E5%AE%9A%E4%BD%8D%E5%BE%85%E5%88%A0%E9%99%A4%E8%AE%B0%E5%BD%95%E5%9C%A8B%2B%E6%A0%91%E4%B8%AD%E4%BD%8D%E7%BD%AE%E7%9A%84%E8%BF%87%E7%A8%8B%E6%98%AF%E4%B8%80%E4%B8%AA%E8%8E%B7%E5%8F%96X%E9%94%81%E7%9A%84**%E9%94%81%E5%AE%9A%E8%AF%BB**%E3%80%82%0A%0A%0A*%20**UPDATE**%0A%E5%9C%A8%E5%AF%B9%E4%B8%80%E6%9D%A1%E8%AE%B0%E5%BD%95%E5%81%9AUPDATE%E6%93%8D%E4%BD%9C%E6%97%B6%E5%88%86%E4%B8%BA%E4%B8%89%E7%A7%8D%E6%83%85%E5%86%B5%EF%BC%9A%0A!%5B5c3f46a2cc107e3ac2ab8e911109ee1b.png%5D(en-resource%3A%2F%2Fdatabase%2F1003%3A1)%0A%0A*%20**INSERT**%0A%E4%B8%80%E8%88%AC%E6%83%85%E5%86%B5%E4%B8%8B%EF%BC%8C%E6%96%B0%E6%8F%92%E5%85%A5%E4%B8%80%E6%9D%A1%E8%AE%B0%E5%BD%95%E7%9A%84%E6%93%8D%E4%BD%9C%E5%B9%B6%E4%B8%8D%E5%8A%A0%E9%94%81%EF%BC%88%E5%9C%A8%E4%B8%80%E4%BA%9B%E7%89%B9%E6%AE%8A%E6%83%85%E5%86%B5%E4%B8%8B%EF%BC%8Cinsert%E6%93%8D%E4%BD%9C%E4%B9%9F%E6%98%AF%E4%BC%9A%E8%8E%B7%E5%8F%96%E9%94%81%E7%9A%84%EF%BC%89%EF%BC%8CInnoDB%E9%80%9A%E8%BF%87**%E9%9A%90%E5%BC%8F%E9%94%81**%E6%9D%A5%E4%BF%9D%E6%8A%A4%E8%BF%99%E6%9D%A1%E6%96%B0%E6%8F%92%E5%85%A5%E7%9A%84%E8%AE%B0%E5%BD%95%E5%9C%A8%E6%9C%AC%E4%BA%8B%E5%8A%A1%E6%8F%90%E4%BA%A4%E5%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8%A2%AB%E4%B8%8A**S%E9%94%81%E5%92%8CX%E9%94%81**%E3%80%82%E9%82%A3%E6%80%8E%E4%B9%88%E5%88%A4%E6%96%AD%E8%BF%99%E4%B8%AA%E5%89%8D%E6%8F%90%E5%91%A2%EF%BC%8CInnoDB%E6%8F%90%E5%87%BA%E4%BA%86%E4%B8%80%E7%A7%8D%E9%94%81%EF%BC%8C%E7%A7%B0%E4%B9%8B%E4%B8%BA**%E6%84%8F%E5%90%91%E9%94%81%EF%BC%88Intention%20Locks%EF%BC%89**%E3%80%82%0A%0A*%20**%E6%84%8F%E5%90%91%E5%85%B1%E4%BA%AB%E9%94%81%EF%BC%8CIntention%20Shared%20Lock%EF%BC%8C%E7%AE%80%E7%A7%B0IS%E9%94%81**%E3%80%82%E5%BD%93%E4%BA%8B%E5%8A%A1%E5%87%86%E5%A4%87%E5%9C%A8%E6%9F%90%E6%9D%A1%E8%AE%B0%E5%BD%95%E4%B8%8A%E5%8A%A0S%E9%94%81%E6%97%B6%EF%BC%8C%E9%9C%80%E8%A6%81%E5%85%88%E5%9C%A8%E8%A1%A8%E7%BA%A7%E5%8A%A0%E4%B8%8A%E4%B8%80%E4%B8%AA**IS%E9%94%81**%E3%80%82%0A*%20**%E6%84%8F%E5%90%91%E7%8B%AC%E5%8D%A0%E9%94%81%EF%BC%8CIntention%20Exclusive%20Lock%EF%BC%8C%E7%AE%80%E7%A7%B0IX%E9%94%81**%E3%80%82%E5%BD%93%E4%BA%8B%E5%8A%A1%E5%87%86%E5%A4%87%E5%9C%A8%E6%9F%90%E6%9D%A1%E8%AE%B0%E5%BD%95%E4%B8%8A%E5%8A%A0X%E9%94%81%E6%97%B6%EF%BC%8C%E9%9C%80%E8%A6%81%E5%85%88%E5%9C%A8%E8%A1%A8%E7%BA%A7%E5%88%AB%E5%8A%A0%E4%B8%8A%E4%B8%80%E4%B8%AA**IX%E9%94%81**%E3%80%82%0A%0A%E6%80%BB%E7%BB%93%E4%B8%80%E4%B8%8B%EF%BC%9A**IS%E3%80%81IX%E9%94%81%E6%98%AF%E8%A1%A8%E7%BA%A7%E9%94%81%EF%BC%8C%E5%AE%83%E4%BB%AC%E7%9A%84%E6%8F%90%E5%87%BA%E4%BB%85%E4%BB%85%E4%B8%BA%E4%BA%86%E5%9C%A8%E4%B9%8B%E5%90%8E%E5%8A%A0%E8%A1%A8%E7%BA%A7%E5%88%AB%E7%9A%84S%E9%94%81%E5%92%8CX%E9%94%81%E6%97%B6%E5%8F%AF%E4%BB%A5%E5%BF%AB%E9%80%9F%E5%88%A4%E6%96%AD%E8%A1%A8%E4%B8%AD%E7%9A%84%E8%AE%B0%E5%BD%95%E6%98%AF%E5%90%A6%E8%A2%AB%E4%B8%8A%E9%94%81%EF%BC%8C%E4%BB%A5%E9%81%BF%E5%85%8D%E7%94%A8%E9%81%8D%E5%8E%86%E7%9A%84%E6%96%B9%E5%BC%8F%E6%9D%A5%E6%9F%A5%E7%9C%8B%E8%A1%A8%E4%B8%AD%E6%9C%89%E6%B2%A1%E6%9C%89%E4%B8%8A%E9%94%81%E7%9A%84%E8%AE%B0%E5%BD%95%EF%BC%8C%E4%B9%9F%E5%B0%B1%E6%98%AF%E8%AF%B4%E5%85%B6%E5%AE%9EIS%E9%94%81%E5%92%8CIX%E9%94%81%E6%98%AF%E5%85%BC%E5%AE%B9%E7%9A%84%EF%BC%8CIX%E9%94%81%E5%92%8CIX%E9%94%81%E6%98%AF%E5%85%BC%E5%AE%B9%E7%9A%84**%E3%80%82%0A%0A%E8%A1%A8%E7%BA%A7%E5%88%AB%E7%9A%84%E5%90%84%E7%A7%8D%E9%94%81%E7%9A%84%E5%85%BC%E5%AE%B9%E6%80%A7%E5%A6%82%E4%B8%8B%EF%BC%9A%0A!%5B2880847d1108df2d560993dd4e205d28.png%5D(en-resource%3A%2F%2Fdatabase%2F1004%3A1)%0A%0A%23%23%204%20MySQL%E4%B8%AD%E7%9A%84%E8%A1%8C%E9%94%81%E5%92%8C%E8%A1%A8%E9%94%81%0A%0AMySQL%E6%94%AF%E6%8C%81%E5%BE%88%E5%A4%9A%E7%A7%8D%E5%AD%98%E5%82%A8%E5%BC%95%E6%93%8E%EF%BC%8C%E4%B8%8D%E5%90%8C%E5%AD%98%E5%82%A8%E5%BC%95%E6%93%8E%E5%AF%B9%E9%94%81%E7%9A%84%E6%94%AF%E6%8C%81%E4%B9%9F%E4%B8%8D%E4%B8%80%E6%A0%B7%EF%BC%8C%E9%87%8D%E7%82%B9%E8%AE%A8%E8%AE%BAInnoDB%E5%AD%98%E5%82%A8%E5%BC%95%E6%93%8E%E4%B8%AD%E7%9A%84%E9%94%81%E3%80%82%0A%0A%23%23%23%204-1%20%E5%85%B6%E4%BB%96%E5%AD%98%E5%82%A8%E5%BC%95%E6%93%8E%E4%B8%AD%E7%9A%84%E9%94%81%0A%0A%E5%AF%B9%E4%BA%8E**MyISAM%E3%80%81MEMORY%E3%80%81MERGE**%E8%BF%99%E4%BA%9B%E5%AD%98%E5%82%A8%E5%BC%95%E6%93%8E%E6%9D%A5%E8%AF%B4%EF%BC%8C%E5%AE%83%E4%BB%AC%E5%8F%AA%E6%94%AF%E6%8C%81**%E8%A1%A8%E7%BA%A7%E9%94%81**%EF%BC%8C%E8%80%8C%E4%B8%94%E8%BF%99%E4%BA%9B%E5%BC%95%E6%93%8E%E5%B9%B6%E4%B8%8D%E6%94%AF%E6%8C%81%E4%BA%8B%E5%8A%A1%EF%BC%8C%E6%89%80%E4%BB%A5%E4%BD%BF%E7%94%A8%E8%BF%99%E4%BA%9B%E5%AD%98%E5%82%A8%E5%BC%95%E6%93%8E%E7%9A%84%E9%94%81%E4%B8%80%E8%88%AC%E9%83%BD%E6%98%AF%E9%92%88%E5%AF%B9%E5%BD%93%E5%89%8D%E4%BC%9A%E8%AF%9D%E6%9D%A5%E8%AF%B4%E7%9A%84%E3%80%82%0A%0A%E5%9B%A0%E4%B8%BA%E4%BD%BF%E7%94%A8MyISAM%E3%80%81MEMORY%E3%80%81MERGE%E8%BF%99%E4%BA%9B%E5%AD%98%E5%82%A8%E5%BC%95%E6%93%8E%E7%9A%84%E8%A1%A8%E5%9C%A8%E5%90%8C%E4%B8%80%E6%97%B6%E5%88%BB%E5%8F%AA%E5%85%81%E8%AE%B8%E4%B8%80%E4%B8%AA%E4%BC%9A%E8%AF%9D%E5%AF%B9%E8%A1%A8%E8%BF%9B%E8%A1%8C%E5%86%99%E6%93%8D%E4%BD%9C%EF%BC%8C%E6%89%80%E4%BB%A5%E8%BF%99%E4%BA%9B%E5%AD%98%E5%82%A8%E5%BC%95%E6%93%8E%E5%AE%9E%E9%99%85%E4%B8%8A%E6%9C%80%E5%A5%BD%E7%94%A8%E5%9C%A8%E5%8F%AA%E8%AF%BB%EF%BC%8C%E6%88%96%E8%80%85%E5%A4%A7%E9%83%A8%E5%88%86%E9%83%BD%E6%98%AF%E8%AF%BB%E6%93%8D%E4%BD%9C%EF%BC%8C%E6%88%96%E8%80%85%E5%8D%95%E7%94%A8%E6%88%B7%E7%9A%84%E6%83%85%E6%99%AF%E4%B8%8B%E3%80%82%E5%8F%A6%E5%A4%96%EF%BC%8C%E5%9C%A8**MyISAM**%E5%AD%98%E5%82%A8%E5%BC%95%E6%93%8E%E4%B8%AD%E6%9C%89%E4%B8%80%E4%B8%AA%E7%A7%B0%E4%B9%8B%E4%B8%BA**Concurrent%20Inserts**%E7%9A%84%E7%89%B9%E6%80%A7%EF%BC%8C%E6%94%AF%E6%8C%81%E5%9C%A8%E5%AF%B9MyISAM%E8%A1%A8%E8%AF%BB%E5%8F%96%E6%97%B6%E5%90%8C%E6%97%B6%E6%8F%92%E5%85%A5%E8%AE%B0%E5%BD%95%EF%BC%8C%E8%BF%99%E4%B9%9F%E5%8F%AF%E4%BB%A5%E6%8F%90%E5%8D%87%E6%8F%92%E5%85%A5%E9%80%9F%E5%BA%A6%E3%80%82%0A%0A%23%23%23%204-2%20InnoDB%E5%AD%98%E5%82%A8%E5%BC%95%E6%93%8E%E4%B8%AD%E7%9A%84%E9%94%81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%9F%90%E4%B8%AA%E8%A1%A8%E6%89%A7%E8%A1%8Cselect%E3%80%81insert%E3%80%81update%E3%80%81delete%E8%AF%AD%E5%8F%A5%E6%97%B6%EF%BC%8CInnoDB%E5%AD%98%E5%82%A8%E5%BC%95%E6%93%8E%E6%98%AF%E4%B8%8D%E4%BC%9A%E4%B8%BA%E8%BF%99%E4%B8%AA%E8%A1%A8%E6%B7%BB%E5%8A%A0%E8%A1%A8%E7%BA%A7%E5%88%AB%E7%9A%84**S%E9%94%81**%E6%88%96%E8%80%85**X%E9%94%81**%E7%9A%84%E3%80%82%0A%0A%E5%8F%A6%E5%A4%96%EF%BC%8C%E5%9C%A8%E5%AF%B9%E6%9F%90%E4%B8%AA%E8%A1%A8%E6%89%A7%E8%A1%8C%E4%B8%80%E4%BA%9B%E8%AF%B8%E5%A6%82ALTER%20TABLE%E3%80%81DROP%20TABLE%E8%BF%99%E7%B1%BB%E7%9A%84DDL%E8%AF%AD%E5%8F%A5%E6%97%B6%EF%BC%8C%E5%85%B6%E4%BB%96%E4%BA%8B%E5%8A%A1%E5%AF%B9%E8%BF%99%E4%B8%AA%E8%A1%A8%E5%B9%B6%E5%8F%91%E6%89%A7%E8%A1%8C%E8%AF%B8%E5%A6%82SELECT%E3%80%81INSERT%E3%80%81DELETE%E3%80%81UPDATE%E7%9A%84%E8%AF%AD%E5%8F%A5%E4%BC%9A%E5%8F%91%E7%94%9F%E9%98%BB%E5%A1%9E%EF%BC%8C%E5%90%8C%E7%90%86%EF%BC%8C%E6%9F%90%E4%B8%AA%E4%BA%8B%E5%8A%A1%E4%B8%AD%E5%AF%B9%E6%9F%90%E4%B8%AA%E8%A1%A8%E6%89%A7%E8%A1%8CSELECT%E3%80%81INSERT%E3%80%81DELETE%E3%80%81UPDATE%E8%AF%AD%E5%8F%A5%E6%97%B6%EF%BC%8C%E5%9C%A8%E5%85%B6%E4%BB%96%E4%BC%9A%E8%AF%9D%E4%B8%AD%E5%AF%B9%E8%BF%99%E4%B8%AA%E8%A1%A8%E6%89%A7%E8%A1%8CDDL%E8%AF%AD%E5%8F%A5%E4%B9%9F%E4%BC%9A%E5%8F%91%E7%94%9F%E9%98%BB%E5%A1%9E%E3%80%82%E8%BF%99%E4%B8%AA%E8%BF%87%E7%A8%8B%E6%98%AF%E9%80%9A%E8%BF%87**server%E5%B1%82**%E4%BD%BF%E7%94%A8%E7%9A%84**%E5%85%83%E6%95%B0%E6%8D%AE%E9%94%81%EF%BC%88Metadata%20Locks%EF%BC%8C%E7%AE%80%E7%A7%B0MDL%EF%BC%89**%E6%9D%A5%E5%AE%9E%E7%8E%B0%E7%9A%84%EF%BC%8C%E4%B8%80%E8%88%AC%E6%83%85%E5%86%B5%E4%B8%8B%E4%B9%9F%E4%B8%8D%E4%BC%9A%E4%BD%BF%E7%94%A8InnoDB%E5%AD%98%E5%82%A8%E5%BC%95%E6%93%8E%E8%87%AA%E5%B7%B1%E6%8F%90%E4%BE%9B%E7%9A%84%E8%A1%A8%E7%BA%A7%E5%88%AB%E7%9A%84**S%E9%94%81**%E5%92%8C**X%E9%94%81**%E3%80%82%0A%0A%E5%85%B6%E5%AE%9EInnoDB%E5%AD%98%E5%82%A8%E5%BC%95%E6%93%8E%E6%8F%90%E4%BE%9B%E7%9A%84%E8%A1%A8%E7%BA%A7S%E9%94%81%E6%88%96%E8%80%85X%E9%94%81%E6%98%AF%E7%9B%B8%E5%BD%93%E9%B8%A1%E8%82%8B%EF%BC%8C%E5%8F%AA%E4%BC%9A%E5%9C%A8%E4%B8%80%E4%BA%9B%E7%89%B9%E6%AE%8A%E6%83%85%E5%86%B5%E4%B8%8B%EF%BC%8C%E6%AF%94%E6%96%B9%E8%AF%B4%E5%B4%A9%E6%BA%83%E6%81%A2%E5%A4%8D%E8%BF%87%E7%A8%8B%E4%B8%AD%E7%94%A8%E5%88%B0%E3%80%82%E4%B8%8D%E8%BF%87%E6%88%91%E4%BB%AC%E8%BF%98%E6%98%AF%E5%8F%AF%E4%BB%A5%E6%89%8B%E5%8A%A8%E8%8E%B7%E5%8F%96%E4%B8%80%E4%B8%8B%E7%9A%84%EF%BC%8C%E6%AF%94%E6%96%B9%E8%AF%B4%E5%9C%A8%E7%B3%BB%E7%BB%9F%E5%8F%98%E9%87%8F**autocommit%20%3D%200%EF%BC%8Cinnodb_table_locks%20%3D%201**%E6%97%B6%EF%BC%8C%E6%89%8B%E5%8A%A8%E8%8E%B7%E5%8F%96InnoDB%E5%AD%98%E5%82%A8%E5%BC%95%E6%93%8E%E6%8F%90%E4%BE%9B%E7%9A%84%E8%A1%A8t%E7%9A%84S%E9%94%81%E6%88%96%E8%80%85X%E9%94%81%E5%8F%AF%E4%BB%A5%E8%BF%99%E4%B9%88%E5%86%99%EF%BC%9A%0A%0A**a.%20LOCK%20TABLES%20t%20READ%EF%BC%9AInnoDB%E5%AD%98%E5%82%A8%E5%BC%95%E6%93%8E%E4%BC%9A%E5%AF%B9%E8%A1%A8t%E5%8A%A0%E8%A1%A8%E7%BA%A7%E5%88%AB%E7%9A%84S%E9%94%81%E3%80%82**%0A**b.%20LOCK%20TABLES%20t%20WRITE%EF%BC%9AInnoDB%E5%AD%98%E5%82%A8%E5%BC%95%E6%93%8E%E4%BC%9A%E5%AF%B9%E8%A1%A8t%E5%8A%A0%E8%A1%A8%E7%BA%A7%E5%88%AB%E7%9A%84X%E9%94%81%E3%80%82**%0A%0A%E4%B8%8D%E8%BF%87%E8%AF%B7%E5%B0%BD%E9%87%8F%E9%81%BF%E5%85%8D%E5%9C%A8%E4%BD%BF%E7%94%A8InnoDB%E5%AD%98%E5%82%A8%E5%BC%95%E6%93%8E%E7%9A%84%E8%A1%A8%E4%B8%8A%E4%BD%BF%E7%94%A8**LOCK%20TABLES**%E8%BF%99%E6%A0%B7%E7%9A%84%E6%89%8B%E5%8A%A8%E9%94%81%E8%A1%A8%E8%AF%AD%E5%8F%A5%EF%BC%8C%E5%AE%83%E4%BB%AC%E5%B9%B6%E4%B8%8D%E4%BC%9A%E6%8F%90%E4%B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A%84%E6%96%B9%E5%BC%8F%E5%AF%B9AUTO_INCREMENT%E4%BF%AE%E9%A5%B0%E7%9A%84%E5%88%97%E8%BF%9B%E8%A1%8C%E8%B5%8B%E5%80%BC%E3%80%82%E8%BF%99%E7%A7%8D%E6%96%B9%E5%BC%8F%E5%8F%AF%E4%BB%A5%E9%81%BF%E5%85%8D%E9%94%81%E5%AE%9A%E8%A1%A8%EF%BC%8C%E5%8F%AF%E4%BB%A5%E6%8F%90%E5%8D%87%E6%8F%92%E5%85%A5%E6%80%A7%E8%83%BD%E3%80%82%0A%0A%0AInnoDB%E6%8F%90%E4%BE%9B%E4%BA%86%E4%B8%80%E4%B8%AA%E7%A7%B0%E4%B9%8B%E4%B8%BA**innodb_autoinc_lock_mode**%E7%9A%84%E7%B3%BB%E7%BB%9F%E5%8F%98%E9%87%8F%E6%9D%A5%E6%8E%A7%E5%88%B6%E5%88%B0%E5%BA%95%E4%BD%BF%E7%94%A8%E4%B8%8A%E8%BF%B0%E4%B8%A4%E7%A7%8D%E6%96%B9%E5%BC%8F%E4%B8%AD%E7%9A%84%E5%93%AA%E7%A7%8D%E6%9D%A5%E4%B8%BAAUTO_INCREMENT%E4%BF%AE%E9%A5%B0%E7%9A%84%E5%88%97%E8%BF%9B%E8%A1%8C%E8%B5%8B%E5%80%BC%EF%BC%9A%0A%0A*%20%E5%BD%93innodb_autoinc_lock_mode%E5%80%BC%E4%B8%BA0%E6%97%B6%EF%BC%8C%E4%B8%80%E5%BE%8B%E9%87%87%E7%94%A8AUTO-INC%E9%94%81%EF%BC%9B%0A*%20%E5%BD%93innodb_autoinc_lock_mode%E5%80%BC%E4%B8%BA2%E6%97%B6%EF%BC%8C%E4%B8%80%E5%BE%8B%E9%87%87%E7%94%A8%E8%BD%BB%E9%87%8F%E7%BA%A7%E9%94%81%EF%BC%9B%0A*%20%E5%BD%93innodb_autoinc_lock_mode%E5%80%BC%E4%B8%BA1%E6%97%B6%EF%BC%8C%E4%B8%A4%E7%A7%8D%E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9A%84%E9%94%81%E3%80%82%E8%A1%8C%E9%94%81%E5%8F%AF%E4%BB%A5%E5%88%86%E4%B8%BA%E5%BE%88%E5%A4%9A%E7%A7%8D%E7%B1%BB%E5%9E%8B%E3%80%82%E6%8D%A2%E5%8F%A5%E8%AF%9D%E8%AF%B4%E5%8D%B3%E4%BD%BF%E5%AF%B9%E5%90%8C%E4%B8%80%E6%9D%A1%E8%AE%B0%E5%BD%95%E5%8A%A0%E8%A1%8C%E9%94%81%EF%BC%8C%E5%A6%82%E6%9E%9C%E7%B1%BB%E5%9E%8B%E4%B8%8D%E5%90%8C%EF%BC%8C%E8%B5%B7%E5%88%B0%E7%9A%84%E5%8A%9F%E6%95%88%E4%B9%9F%E6%98%AF%E4%B8%8D%E5%90%8C%E7%9A%84%E3%80%82%E4%B8%BA%E4%BA%86%E6%95%85%E4%BA%8B%E7%9A%84%E9%A1%BA%E5%88%A9%E5%8F%91%E5%B1%95%EF%BC%8C%E6%88%91%E4%BB%AC%E8%BF%98%E6%98%AF%E5%85%88%E5%B0%86%E4%B9%8B%E5%89%8D%E5%94%A0%E5%8F%A8MVCC%E6%97%B6%E7%94%A8%E5%88%B0%E7%9A%84%E8%A1%A8%E6%8A%84%E4%B8%80%E9%81%8D%EF%BC%9A%0A!%5Be0763a99fbcdf0b4773b77d79ed3ecfc.png%5D(en-resource%3A%2F%2Fdatabase%2F1007%3A1)%0A%0A%E6%8A%8Ahero%E8%A1%A8%E4%B8%AD%E7%9A%84%E8%81%9A%E7%B0%87%E7%B4%A2%E5%BC%95%E7%9A%84%E7%A4%BA%E6%84%8F%E5%9B%BE%E7%94%BB%E4%B8%80%E4%B8%8B%EF%BC%9A%0A!%5B87c4797877d62bea24d03eac64119895.jpeg%5D(en-resource%3A%2F%2Fdatabase%2F1006%3A1)%0A%0A%E4%B8%8B%E9%9D%A2%E6%9D%A5%E7%9C%8B%E4%B8%80%E4%B8%8B%E8%A1%8C%E9%94%81%E7%B1%BB%E5%9E%8B%EF%BC%9A%0A%0A%23%23%23%23%20Records%20Locks%0A%0A%E5%89%8D%E8%BE%B9%E6%8F%90%E5%88%B0%E7%9A%84%E8%AE%B0%E5%BD%95%E9%94%81%E5%B0%B1%E6%98%AF%E8%BF%99%E7%A7%8D%E7%B1%BB%E5%9E%8B%EF%BC%8C%E4%B9%9F%E5%B0%B1%E6%98%AF%E4%BB%85%E4%BB%85%E6%8A%8A%E4%B8%80%E6%9D%A1%E8%AE%B0%E5%BD%95%E9%94%81%E4%B8%8A%EF%BC%8C%E5%AE%98%E6%96%B9%E7%9A%84%E7%B1%BB%E5%9E%8B%E5%90%8D%E7%A7%B0%E4%B8%BA%EF%BC%9A**LOCK_REC_NOT_GAP**%E3%80%82%E6%AF%94%E6%96%B9%E8%AF%B4%E6%88%91%E4%BB%AC%E6%8A%8Anumber%E5%80%BC%E4%B8%BA8%E7%9A%84%E9%82%A3%E6%9D%A1%E8%AE%B0%E5%BD%95%E5%8A%A0%E4%B8%80%E4%B8%AA%E6%AD%A3%E7%BB%8F%E8%AE%B0%E5%BD%95%E9%94%81%E7%9A%84%E7%A4%BA%E6%84%8F%E5%9B%BE%E5%A6%82%E4%B8%8B%EF%BC%9A%0A!%5B7200f483325a6e358b6f8a5d45433462.jpeg%5D(en-resource%3A%2F%2Fdatabase%2F1005%3A1)%0A%0A**Records%20Locks**%E6%98%AF%E6%9C%89S%E9%94%81%E5%92%8CX%E9%94%81%E4%B9%8B%E5%88%86%E7%9A%84%EF%BC%8C%E5%BD%93%E4%B8%80%E4%B8%AA%E4%BA%8B%E5%8A%A1%E8%8E%B7%E5%8F%96%E4%BA%86%E4%B8%80%E6%9D%A1%E8%AE%B0%E5%BD%95%E7%9A%84**S%E5%9E%8BRecords%20Locks**%E8%AE%B0%E5%BD%95%E9%94%81%E5%90%8E%EF%BC%8C%E5%85%B6%E4%BB%96%E4%BA%8B%E5%8A%A1%E4%B9%9F%E5%8F%AF%E4%BB%A5%E7%BB%A7%E7%BB%AD%E8%8E%B7%E5%8F%96%E8%AF%A5%E8%AE%B0%E5%BD%95%E7%9A%84**S%E5%9E%8BRecords%20Locks**%E8%AE%B0%E5%BD%95%E9%94%81%EF%BC%8C%E4%BD%86%E4%B8%8D%E5%8F%AF%E4%BB%A5%E7%BB%A7%E7%BB%AD%E8%8E%B7%E5%8F%96**X%E5%9E%8BRecords%20Locks**%E8%AE%B0%E5%BD%95%E9%94%81%EF%BC%9B%E5%BD%93%E4%B8%80%E4%B8%AA%E4%BA%8B%E5%8A%A1%E8%8E%B7%E5%8F%96%E4%BA%86%E4%B8%80%E6%9D%A1%E8%AE%B0%E5%BD%95%E7%9A%84**X%E5%9E%8BRecords%20Locks**%E8%AE%B0%E5%BD%95%E9%94%81%E5%90%8E%EF%BC%8C%E5%85%B6%E4%BB%96%E4%BA%8B%E5%8A%A1%E6%97%A2%E4%B8%8D%E5%8F%AF%E4%BB%A5%E7%BB%A7%E7%BB%AD%E8%8E%B7%E5%8F%96%E8%AF%A5%E8%AE%B0%E5%BD%95%E7%9A%84**S%E5%9E%8BRecords%20Locks**%E8%AE%B0%E5%BD%95%E9%94%81%EF%BC%8C%E4%B9%9F%E4%B8%8D%E5%8F%AF%E4%BB%A5%E7%BB%A7%E7%BB%AD%E8%8E%B7%E5%8F%96**X%E5%9E%8BRecords%20Locks**%E8%AE%B0%E5%BD%95%E9%94%81%EF%BC%9B%0A%0A%23%23%23%23%20Gap%20Locks%0A%0AMySQL%E5%9C%A8REPEATABLE%20READ%E9%9A%94%E7%A6%BB%E7%BA%A7%E5%88%AB%E4%B8%8B%E6%98%AF%E5%8F%AF%E4%BB%A5%E8%A7%A3%E5%86%B3%E5%B9%BB%E8%AF%BB%E9%97%AE%E9%A2%98%E7%9A%84%EF%BC%8C%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88%E6%9C%89%E4%B8%A4%E7%A7%8D%EF%BC%8C%E5%8F%AF%E4%BB%A5%E4%BD%BF%E7%94%A8MVCC%E6%96%B9%E6%A1%88%E8%A7%A3%E5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%B0%E5%BD%95%E5%8A%A0%E4%B8%80%E4%B8%AAgap%E9%94%81%E7%9A%84%E7%A4%BA%E6%84%8F%E5%9B%BE%E5%A6%82%E4%B8%8B%EF%BC%9A%0A!%5Bbc72547e7c66e78cef0d3efb634b8485.jpeg%5D(en-resource%3A%2F%2Fdatabase%2F1008%3A1)%0A%0A%E5%A6%82%E5%9B%BE%E4%B8%AD%E4%B8%BAnumber%E5%80%BC%E4%B8%BA8%E7%9A%84%E8%AE%B0%E5%BD%95%E5%8A%A0%E4%BA%86gap%E9%94%81%EF%BC%8C%E6%84%8F%E5%91%B3%E7%9D%80%E4%B8%8D%E5%85%81%E8%AE%B8%E5%88%AB%E7%9A%84%E4%BA%8B%E5%8A%A1%E5%9C%A8number%E5%80%BC%E4%B8%BA8%E7%9A%84%E8%AE%B0%E5%BD%95%E5%89%8D%E8%BE%B9%E7%9A%84%E9%97%B4%E9%9A%99%E6%8F%92%E5%85%A5%E6%96%B0%E8%AE%B0%E5%BD%95%EF%BC%8C%E5%85%B6%E5%AE%9E%E5%B0%B1%E6%98%AFnumber%E5%88%97%E7%9A%84%E5%80%BC(3%2C%208)%E8%BF%99%E4%B8%AA%E5%8C%BA%E9%97%B4%E7%9A%84%E6%96%B0%E8%AE%B0%E5%BD%95%E6%98%AF%E4%B8%8D%E5%85%81%E8%AE%B8%E7%AB%8B%E5%8D%B3%E6%8F%92%E5%85%A5%E7%9A%84%E3%80%82%E6%AF%94%E6%96%B9%E8%AF%B4%E6%9C%89%E5%8F%A6%E5%A4%96%E4%B8%80%E4%B8%AA%E4%BA%8B%E5%8A%A1%E5%86%8D%E6%83%B3%E6%8F%92%E5%85%A5%E4%B8%80%E6%9D%A1number%E5%80%BC%E4%B8%BA4%E7%9A%84%E6%96%B0%E8%AE%B0%E5%BD%95%EF%BC%8C%E5%AE%83%E5%AE%9A%E4%BD%8D%E5%88%B0%E8%AF%A5%E6%9D%A1%E6%96%B0%E8%AE%B0%E5%BD%95%E7%9A%84%E4%B8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B4%E7%9A%84%E6%96%B0%E8%AE%B0%E5%BD%95%E3%80%82%E4%B8%BA%E4%BA%86%E5%A4%A7%E5%AE%B6%E7%90%86%E8%A7%A3%E6%96%B9%E4%BE%BF%EF%BC%8C%E4%B9%8B%E5%90%8E%E7%9A%84%E7%B4%A2%E5%BC%95%E7%A4%BA%E6%84%8F%E5%9B%BE%E4%B8%AD%E9%83%BD%E4%BC%9A%E6%8A%8A%E8%BF%99%E4%B8%AASupremum%E8%AE%B0%E5%BD%95%E7%94%BB%E5%87%BA%E6%9D%A5%E3%80%82%0A%0A%23%23%23%23%20Next-Key%20Locks%0A%0A%E6%9C%89%E6%97%B6%E5%80%99%E6%97%A2%E6%83%B3%E9%94%81%E4%BD%8F%E6%9F%90%E6%9D%A1%E8%AE%B0%E5%BD%95%EF%BC%8C%E5%8F%88%E6%83%B3%E9%98%BB%E6%AD%A2%E5%85%B6%E4%BB%96%E4%BA%8B%E5%8A%A1%E5%9C%A8%E8%AF%A5%E8%AE%B0%E5%BD%95%E5%89%8D%E8%BE%B9%E7%9A%84%E9%97%B4%E9%9A%99%E6%8F%92%E5%85%A5%E6%96%B0%E8%AE%B0%E5%BD%95%EF%BC%8CInnoDB%E5%B0%B1%E6%8F%90%E5%87%BA%E4%BA%86%E4%B8%80%E7%A7%8D%E7%A7%B0%E4%B9%8B%E4%B8%BA**Next-Key%20Locks**%E7%9A%84%E9%94%81%EF%BC%8C%E5%AE%98%E6%96%B9%E7%9A%84%E7%B1%BB%E5%9E%8B%E5%90%8D%E7%A7%B0%E4%B8%BA%EF%BC%9A**LOCK_ORDINARY**%EF%BC%8C%E4%B9%9F%E5%8F%AF%E4%BB%A5%E7%AE%80%E7%A7%B0%E4%B8%BAnext-key%E9%94%81%E3%80%82%E6%AF%94%E6%96%B9%E8%AF%B4%E6%8A%8Anumber%E5%80%BC%E4%B8%BA8%E7%9A%84%E9%82%A3%E6%9D%A1%E8%AE%B0%E5%BD%95%E5%8A%A0%E4%B8%80%E4%B8%AAnext-key%E9%94%81%E7%9A%84%E7%A4%BA%E6%84%8F%E5%9B%BE%E5%A6%82%E4%B8%8B%EF%BC%9A%0A!%5B42f5e0ecfd05ad6ce59d6d846c28ec7b.jpeg%5D(en-resource%3A%2F%2Fdatabase%2F1009%3A1)%0A%0Anext-key%E9%94%81%E7%9A%84%E6%9C%AC%E8%B4%A8%E5%B0%B1%E6%98%AF%E4%B8%80%E4%B8%AArecord%E9%94%81%E5%92%8C%E4%B8%80%E4%B8%AAgap%E9%94%81%E7%9A%84%E5%90%88%E4%BD%93%EF%BC%8C%E5%AE%83%E6%97%A2%E8%83%BD%E4%BF%9D%E6%8A%A4%E8%AF%A5%E6%9D%A1%E8%AE%B0%E5%BD%95%EF%BC%8C%E5%8F%88%E8%83%BD%E9%98%BB%E6%AD%A2%E5%88%AB%E7%9A%84%E4%BA%8B%E5%8A%A1%E5%B0%86%E6%96%B0%E8%AE%B0%E5%BD%95%E6%8F%92%E5%85%A5%E8%A2%AB%E4%BF%9D%E6%8A%A4%E8%AE%B0%E5%BD%95%E5%89%8D%E8%BE%B9%E7%9A%84%E9%97%B4%E9%9A%99%E3%80%82%0A%0A%23%23%23%23%20Insert%20Intention%20Locks%0A%0A%E4%B8%80%E4%B8%AA%E4%BA%8B%E5%8A%A1%E5%9C%A8%E6%8F%92%E5%85%A5%E4%B8%80%E6%9D%A1%E8%AE%B0%E5%BD%95%E6%97%B6%E9%9C%80%E8%A6%81%E5%88%A4%E6%96%AD%E4%B8%80%E4%B8%8B%E6%8F%92%E5%85%A5%E4%BD%8D%E7%BD%AE%E6%98%AF%E4%B8%8D%E6%98%AF%E8%A2%AB%E5%88%AB%E7%9A%84%E4%BA%8B%E5%8A%A1%E5%8A%A0%E4%BA%86%E6%89%80%E8%B0%93%E7%9A%84gap%E9%94%81%EF%BC%8C%E5%A6%82%E6%9E%9C%E6%9C%89%E7%9A%84%E8%AF%9D%EF%BC%8C%E6%8F%92%E5%85%A5%E6%93%8D%E4%BD%9C%E9%9C%80%E8%A6%81%E7%AD%89%E5%BE%85%EF%BC%8C%E7%9B%B4%E5%88%B0%E6%8B%A5%E6%9C%89gap%E9%94%81%E7%9A%84%E9%82%A3%E4%B8%AA%E4%BA%8B%E5%8A%A1%E6%8F%90%E4%BA%A4%E3%80%82%E4%BD%86%E6%98%AFInnoDB%E8%A7%84%E5%AE%9A%E4%BA%8B%E5%8A%A1%E5%9C%A8%E7%AD%89%E5%BE%85%E7%9A%84%E6%97%B6%E5%80%99%E4%B9%9F%E9%9C%80%E8%A6%81%E5%9C%A8%E5%86%85%E5%AD%98%E4%B8%AD%E7%94%9F%E6%88%90%E4%B8%80%E4%B8%AA**%E9%94%81%E7%BB%93%E6%9E%84**%EF%BC%8C%E8%A1%A8%E6%98%8E%E6%9C%89%E4%BA%8B%E5%8A%A1%E6%83%B3%E5%9C%A8%E6%9F%90%E4%B8%AA**%E9%97%B4%E9%9A%99**%E4%B8%AD%E6%8F%92%E5%85%A5%E6%96%B0%E8%AE%B0%E5%BD%95%EF%BC%8C%E4%BD%86%E6%98%AF%E7%8E%B0%E5%9C%A8%E5%9C%A8%E7%AD%89%E5%BE%85%EF%BC%8C%E8%BF%99%E7%A7%8D%E7%B1%BB%E5%9E%8B%E7%9A%84%E9%94%81%E7%A7%B0%E4%B8%BA**Insert%20Intention%20Locks**%EF%BC%8C%E5%AE%98%E6%96%B9%E7%9A%84%E7%B1%BB%E5%9E%8B%E5%90%8D%E7%A7%B0%E4%B8%BA%EF%BC%9A**LOCK_INSERT_INTENTION**%EF%BC%8C%E4%B9%9F%E5%8F%AF%E4%BB%A5%E7%A7%B0%E4%B8%BA**%E6%8F%92%E5%85%A5%E6%84%8F%E5%90%91%E9%94%81**%E3%80%82%0A%0A%0A%E6%AF%94%E6%96%B9%E8%AF%B4%E6%88%91%E4%BB%AC%E6%8A%8Anumber%E5%80%BC%E4%B8%BA8%E7%9A%84%E9%82%A3%E6%9D%A1%E8%AE%B0%E5%BD%95%E5%8A%A0%E4%B8%80%E4%B8%AA%E6%8F%92%E5%85%A5%E6%84%8F%E5%90%91%E9%94%81%E7%9A%84%E7%A4%BA%E6%84%8F%E5%9B%BE%E5%A6%82%E4%B8%8B%EF%BC%9A%0A!%5B545ce68426a03ddf21a812b629150f58.jpeg%5D(en-resource%3A%2F%2Fdatabase%2F1011%3A1)%0A%0A%0A%E4%B8%BA%E4%BA%86%E8%AE%A9%E5%A4%A7%E5%AE%B6%E5%BD%BB%E5%BA%95%E7%90%86%E8%A7%A3%E8%BF%99%E4%B8%AA%E6%8F%92%E5%85%A5%E6%84%8F%E5%90%91%E9%94%81%E7%9A%84%E5%8A%9F%E8%83%BD%EF%BC%8C%E6%88%91%E4%BB%AC%E8%BF%98%E6%98%AF%E4%B8%BE%E4%B8%AA%E4%BE%8B%E5%AD%90%E7%84%B6%E5%90%8E%E7%94%BB%E4%B8%AA%E5%9B%BE%E8%A1%A8%E7%A4%BA%E4%B8%80%E4%B8%8B%E3%80%82%E6%AF%94%E6%96%B9%E8%AF%B4%E7%8E%B0%E5%9C%A8T1%E4%B8%BAnumber%E5%80%BC%E4%B8%BA8%E7%9A%84%E8%AE%B0%E5%BD%95%E5%8A%A0%E4%BA%86%E4%B8%80%E4%B8%AAgap%E9%94%81%EF%BC%8C%E7%84%B6%E5%90%8ET2%E5%92%8CT3%E5%88%86%E5%88%AB%E6%83%B3%E5%90%91hero%E8%A1%A8%E4%B8%AD%E6%8F%92%E5%85%A5number%E5%80%BC%E5%88%86%E5%88%AB%E4%B8%BA4%E3%80%815%E7%9A%84%E4%B8%A4%E6%9D%A1%E8%AE%B0%E5%BD%95%EF%BC%8C%E6%89%80%E4%BB%A5%E7%8E%B0%E5%9C%A8%E4%B8%BAnumber%E5%80%BC%E4%B8%BA8%E7%9A%84%E8%AE%B0%E5%BD%95%E5%8A%A0%E7%9A%84%E9%94%81%E7%9A%84%E7%A4%BA%E6%84%8F%E5%9B%BE%E5%B0%B1%E5%A6%82%E4%B8%8B%E6%89%80%E7%A4%BA%EF%BC%9A%0A!%5B58cca45819393ad734ddc10b155414bb.jpeg%5D(en-resource%3A%2F%2Fdatabase%2F1012%3A1)%0A%0A%0A%E4%BB%8E%E5%9B%BE%E4%B8%AD%E5%8F%AF%E4%BB%A5%E7%9C%8B%E5%88%B0%EF%BC%8C%E7%94%B1%E4%BA%8ET1%E6%8C%81%E6%9C%89gap%E9%94%81%EF%BC%8C%E6%89%80%E4%BB%A5T2%E5%92%8CT3%E9%9C%80%E8%A6%81%E7%94%9F%E6%88%90%E4%B8%80%E4%B8%AA%E6%8F%92%E5%85%A5%E6%84%8F%E5%90%91%E9%94%81%E7%9A%84%E9%94%81%E7%BB%93%E6%9E%84%E5%B9%B6%E4%B8%94%E5%A4%84%E4%BA%8E%E7%AD%89%E5%BE%85%E7%8A%B6%E6%80%81%E3%80%82%E5%BD%93T1%E6%8F%90%E4%BA%A4%E5%90%8E%E4%BC%9A%E6%8A%8A%E5%AE%83%E8%8E%B7%E5%8F%96%E5%88%B0%E7%9A%84%E9%94%81%E9%83%BD%E9%87%8A%E6%94%BE%E6%8E%89%EF%BC%8C%E8%BF%99%E6%A0%B7T2%E5%92%8CT3%E5%B0%B1%E8%83%BD%E8%8E%B7%E5%8F%96%E5%88%B0%E5%AF%B9%E5%BA%94%E7%9A%84%E6%8F%92%E5%85%A5%E6%84%8F%E5%90%91%E9%94%81%E4%BA%86%EF%BC%88%E6%9C%AC%E8%B4%A8%E4%B8%8A%E5%B0%B1%E6%98%AF%E6%8A%8A%E6%8F%92%E5%85%A5%E6%84%8F%E5%90%91%E9%94%81%E5%AF%B9%E5%BA%94%E9%94%81%E7%BB%93%E6%9E%84%E7%9A%84is_waiting%E5%B1%9E%E6%80%A7%E6%94%B9%E4%B8%BAfalse%EF%BC%89%EF%BC%8CT2%E5%92%8CT3%E4%B9%8B%E9%97%B4%E4%B9%9F%E5%B9%B6%E4%B8%8D%E4%BC%9A%E7%9B%B8%E4%BA%92%E9%98%BB%E5%A1%9E%EF%BC%8C%E5%AE%83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%E5%AD%98%E5%9C%A8%EF%BC%8C%E4%BC%9A%E5%85%88%E5%B8%AE%E5%8A%A9%E5%BD%93%E5%89%8D%E4%BA%8B%E5%8A%A1%E7%94%9F%E6%88%90%E4%B8%80%E4%B8%AA%E9%94%81%E7%BB%93%E6%9E%84%EF%BC%8C%E7%84%B6%E5%90%8E%E8%87%AA%E5%B7%B1%E5%86%8D%E7%94%9F%E6%88%90%E4%B8%80%E4%B8%AA%E9%94%81%E7%BB%93%E6%9E%84%E5%90%8E%E8%BF%9B%E5%85%A5%E7%AD%89%E5%BE%85%E7%8A%B6%E6%80%81%E3%80%82%0A%0A%0A%0A</center></span>
</div></body></html> 